// pages/contrast_results/contrast_results.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navTab: [{
        con: "异常指标"
      },
      {
        con: "正常指标"
      },
      {
        con: "全部指标"
      }
    ],
    current: 0,
    yearContrastArr: []
  },
  show_data: function (e) {
    console.log(e)
    var title = e.currentTarget.dataset.title
    var max = e.currentTarget.dataset.max
    var min = e.currentTarget.dataset.min
    var shuju = e.currentTarget.dataset.shuju
    var id = JSON.stringify(this.data.id) 
    var duibid = e.currentTarget.dataset.duibid
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/serachtijian/serachtijian?checkword=' + title+'&id='+id+'&duibid='+duibid
    })
    // this.setData({
    //   show_state: true,
    //   title: title,
    //   max: max,
    //   min: min,
    //   shuju: shuju
    // })
  },
  close_zhe: function (e) {
    this.setData({
      show_state: false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var chooseId = JSON.parse(options.chooseId)
    console.log(chooseId)
    that.setData({
      backgroundColor: bgc,
      id: chooseId
    })
    this.getDuibi()
  },
  //导航切换
  navTab: function (e) {
    console.log(e)
    this.setData({
      current: e.currentTarget.dataset.index
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //对比
  getDuibi: function () {
    var that = this
    var id = that.data.id
    app.util.request({
      'url': 'entry/wxapp/tijian.duibi',
      data: {
        id: id,
        openid:wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        that.setData({
          normal: res.data.normal,
          abnormal: res.data.abnormal,
          whole: res.data.whole,
          duibid:res.data.duibid
        })
      }
    })
  },
  tuijian(e) {
    var that = this
    var sid = e.currentTarget.dataset.sid
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/product/product?fid=&sid=' + sid,
    })
  }
})